home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4024 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: calf.saltfarm.bt.co.uk!not-for-mail
  2. From: aeb@calf.saltfarm.bt.co.uk (Tony Bass)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: function pointers
  5. Date: 1 Feb 1996 10:37:47 -0000
  6. Organization: BT Speech Technology Section
  7. Message-ID: <4eq55r$rgs@calf.saltfarm.bt.co.uk>
  8. References: <4eohgr$gt0@giga.bga.com>
  9. Reply-To: aeb@saltfarm.bt.co.uk
  10. NNTP-Posting-Host: calf.saltfarm.bt.co.uk
  11.  
  12. From article <4eohgr$gt0@giga.bga.com>, by makuch@bga.com (Michael Makuch):
  13. > In article <4eogio$gt0@giga.bga.com>, makuch@bga.com says...
  14. >>
  15. >>The following c code segment compiles and works on
  16. >>NT MSVC++ and on SVR4 C compiler, but errors out
  17. >>on AIX with a type mismatch;
  18. >>
  19. >>struct foostruct1 * myfoo1();
  20. >>struct foostruct2 * myfoo2();
  21. >>void *(*ptr)();
  22. >>
  23. >>ptr = myfoo1;
  24.  
  25.  
  26. Function-type casts are needed,
  27.  
  28.    ptr = (void *(*)())myfoo1;
  29.  
  30. and later at the call
  31.  
  32.    ((struct foostruct1 *(*)())ptr)();
  33.  
  34. It might be possible to make it a bit more readable with typedefs.
  35.  
  36.     Tony Bass
  37.  
  38. -- 
  39. # Tony Bass                                     Tel: (01473) 645305
  40. # MLB 3/19, BT Laboratories                     e-mail: aeb@saltfarm.bt.co.uk
  41. # Martlesham Heath, Ipswich, Suffolk, IP5 7RE   DO NOT e-mail to From: line
  42. #                                               Opinions are my own
  43.